public class Dog {
    //使用构造方法
    /*字段/属性/成员变量：
    定义在类的内部，方法的外部
     */
    public String name;
    public int age;
    public String color;

    public Dog() {
        this("小白", 3, "白色");
        System.out.println("这是一个构造方法");
    }
    //构造方法
    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    public void eat() {
        System.out.println(this.name + "正在吃狗粮！");
    }

    public void sleep() {
        System.out.println(this.name + "正在睡觉！");
    }

    public void show() {
        System.out.println("姓名：" + this.name + " 年龄：" + this.age + " 颜色：" + this.color);
    }

    public static void main(String[] args) {
        //类的实例化
        Dog dog = new Dog();
        dog.show();
        dog.sleep();

        Dog dog1 = new Dog("大黄", 3, "黄色");
        dog1.show();
        dog1.eat();
    }
}
